<?php
namespace app\index\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username'  =>  'require|length:4,10|unique:user,username',
        'email' =>  'email|unique:user,email',
        'password'=>'require|length:4,30|chsDash',
        'repassword'=>'require|confirm:password',
        'vercode'=>'checkCode'
    ];

    protected $message  =   [
        'email'        => '邮箱格式错误',
        'username.length'  => '昵称长度为4-10位',
        'password.length'  => '密码长度不能小于4位',
    	'repassword.confirm'  => '两次密码不一致',
        'vercode.checkCode'  => '人类验证不通过',    
    ];

    protected $scene = [
        // 'login'  =>  ['','password'],
        'set'    =>  ['email','username'],
        'setPassword'=>['password','repassword']
    ];


    public function checkCode($value,$rule,$data)
    {
    	if($value==session('answer')){
    		return true;
    	}else{
    		return false;
    	}
    }

}


?>